import requests


class LoginAPI:

    # 封装一个登录的接口
    @classmethod
    def ihrm_login_api(cls, body):
        url = "http://ihrm2-test.itheima.net/api/sys/login"
        headers = {"Content-Type": "application/json"}
        resp = requests.post(url=url, headers=headers, json=body)
        return resp

    # 封装获取图片验证码接口
    @classmethod
    def get_code_api(cls, session):
        code_url = "http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify"
        session.get(code_url)

    # 封装tpshop登录接口
    @classmethod
    def tpshop_login_api(cls, session, login_body):
        login_url = "http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=do_login"
        login_header = {"Content-Type": "application/x-www-form-urlencoded"}
        login_resp = session.post(url=login_url, headers=login_header, data=login_body)
        return login_resp
